#ifndef BROADCAST_H
#define BROADCAST_H

struct AddrObj : public TListObj 
{
	ULONG	addr;
	int		portNo;
};

struct UrlObj : public TListObj 
{
	char	protocol[MAX_NAMEBUF];
	char	program[MAX_PATH_U8];
};

class TBroadcastObj : public TListObj
{
public:
	TBroadcastObj( const char* host = NULL, ULONG addr = 0 ){ _host = _strdup( host ); _addr = addr; }
	~TBroadcastObj(){ if( _host ) free( _host ); }

	const char* GetHost(){ return _host; }
	ULONG GetAddr( bool realTime = false ){ return realTime ? ( _addr = ResolveAddr(_host) ) : _addr; }

	static ULONG ResolveAddr( const char* host ){return 0;};
private:
	char*	_host;
	ULONG	_addr;
};

class TBroadcastList : public TList
{
public:
	TBroadcastList(){}
	~TBroadcastList(){ Reset(); }
	void Reset()
	{
		TBroadcastObj	*obj;

		while ((obj = Top()) != NULL)
		{
			DelObj(obj);
			delete obj;
		}
	}
	void SetHostRaw( const char* host, ULONG addr = 0 ){ TBroadcastObj* obj = new TBroadcastObj( host, addr ); AddObj( obj ); }
	TBroadcastObj* Top() { return (TBroadcastObj*)TopObj(); }
	TBroadcastObj* Next( TBroadcastObj* obj ){ return (TBroadcastObj*)NextObj( obj ); }
};

#endif	// BROADCAST_H